package com.cardbaobao.cardbabyclient.ui.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.cardbaobao.cardbabyclient.R;
import com.cardbaobao.cardbabyclient.ui.adapter.base.CommonRecyclerAdapter;
import com.cardbaobao.cardbabyclient.ui.adapter.base.CommonRecyclerHolder;
import com.cardbaobao.cardbabyclient.model.LoansApplyRecord;
import com.cardbaobao.cardbabyclient.utils.DensityUtil;
import com.cardbaobao.cardbabyclient.utils.ImageLoaderUtil;
import com.cardbaobao.cardbabyclient.utils.URLUtil;

/**
 * Description: 信用卡申请记录
 * Created by FHW
 * on 2017/7/05
 */

public class LoansApplyRecordRcAdapter extends CommonRecyclerAdapter<LoansApplyRecord> {
    public LoansApplyRecordRcAdapter(Context context) {
        super(context, null, R.layout.item_loans_apply_record);
    }

    @Override
    public void convert(final CommonRecyclerHolder holder, final LoansApplyRecord item) {

//        if (holder.position == 0) {
//            holder.getView(R.id.ll_top).setVisibility(View.VISIBLE);
//        } else {
//            holder.getView(R.id.ll_top).setVisibility(View.GONE);
//        }
        if(holder.getAdapterPosition()==0){
            try{
                ViewGroup.MarginLayoutParams layoutParams=
                        (ViewGroup.MarginLayoutParams) holder.getView(R.id.rl_item).getLayoutParams();
                layoutParams.topMargin= DensityUtil.dp2px(16);
                holder.getView(R.id.rl_item).setLayoutParams(layoutParams);
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        //信用卡logo
        ImageLoaderUtil.displayImage(URLUtil.CBB_IMG_URL + item.getImage(), (ImageView) holder.getView(R.id.iv_pic));
        holder.setTextViewText(R.id.tv_name, item.getProductLoansName());
        holder.setTextViewText(R.id.tv_time, item.getApplyDateTime());
        holder.setTextViewText(R.id.tv_state, item.getStatus());
        holder.setTextViewText(R.id.tv_money, item.getLoansMoney());

//        if ("成功办理".equals(item.getStatus())) {
//            holder.setImageRes(R.id.iv_state, R.mipmap.icon_apply_record_pink);
//        } else if ("未受理".equals(item.getStatus())) {//
//            holder.setImageRes(R.id.iv_state, R.mipmap.icon_apply_record_blue);
//        } else {//已受理
//            holder.setImageRes(R.id.iv_state, R.mipmap.icon_apply_record_yellow);
//        }

    }

}
